import re
import time

from playwright.sync_api import Playwright, sync_playwright, expect


def run(playwright: Playwright) -> None:
    browser = playwright.chromium.launch(headless=False,
                                         slow_mo=1000,
                                         args=["--window-position=800,-850"])
    context = browser.new_context(viewport={"width":1024,"height":768})
    page = context.new_page()
    page.pause()

    page.goto("https://www.baidu.com/")
    page.locator("//input[@id='kw']").fill("城下秋草 CSDN")

    page.locator("#su").click()

    expect(page.locator("#content_left")).to_contain_text("城下秋草的博客-CSDN博客")
    expect(page).to_have_url()
    page.close()

    # ---------------------
    context.close()
    browser.close()


with sync_playwright() as playwright:
    run(playwright)
